<?php

/*
This script shows how to call methods on PBBG Warp's XML-RPC integration server.
You can build snippets of this code into your site to display PBBG Warp information as you like.
*/


// Include the client object
require('client_object.php');


// ************
// Set your game ID and your integration key
// ************

pwIntClient::$gameId = 88;
pwIntClient::$key = 'teh-key-4-integration';

/****************************************
*
*   Get a List of Fans
*
****************************************/

/****************************************
*
*   Get Satellite Ranking Stats
*
****************************************/

// Title
echo '<h1>Get satellite ranking statistics</h1>';

// Get statistics on all relevant satellite rankings
pwIntClient::getSatelliteStats_v1();

// ANOTHER EXAMPLE: Get statistics for Top PBBGs and World PBBGs only
// pwIntClient::getSatelliteStats_v1(array('toppbbgs.com', 'worldpbbgs.com')); 

// ANOTHER EXAMPLE: Get statistics for all rankings and check if the current IP address can vote on each
// pwIntClient::getSatelliteStats_v1(array() , $_SERVER['REMOTE_ADDR']);

// Check for a fault
if (pwIntClient::$fault) {
	echo 'Fault ' . pwIntClient::$faultCode . ' occurred: ' . pwIntClient::$faultMessage;
}
else {
	
	// Get the result array
	$result = pwIntClient::$result;
	
	// Loop through each satellite ranking
	foreach ($result['satellites'] as $curSatellite) {
	
		// Print satellite name and descriptioin
		echo '<b>' . $curSatellite['name'] . ' - ' . $curSatellite['domain'] . '</b><br/>';
		echo $curSatellite['description'] . '<br/>';
		
		// Print a vote icon
		echo '<a href="' . $curSatellite['voteurl'] . '"><img src="' . $curSatellite['voteiconurl'] . '" /></a><br/>';
		
		// Print whether the specified IP can vote on the current satellite ranking
		// If no IP was specified then 'ipcanvote' will not be in the results
		if (isset($curSatellite['ipcanvote']) && $curSatellite['ipcanvote'])
			echo 'Specified IP address can vote.<br/>';
		else if (isset($curSatellite['ipcanvote']) && !$curSatellite['ipcanvote'])
			echo 'Specified IP address must wait before voting.<br/>';
		
		// Print voting statistics for the current satellite ranking
		echo 'Votes Past Week: ' 	. $curSatellite['votespastweek'] 	. ' (Ranked ' . $curSatellite['rankpastweek'] 	. ')<br/>';
		echo 'Votes Past Month: ' 	. $curSatellite['votespastmonth'] 	. ' (Ranked ' . $curSatellite['rankpastmonth'] 	. ')<br/>';
		echo 'Votes Past Year: ' 	. $curSatellite['votespastyear'] 	. ' (Ranked ' . $curSatellite['rankpastyear'] 	. ')<br/>';
		echo 'Votes All Time: ' 	. $curSatellite['votesalltime'] 	. ' (Ranked ' . $curSatellite['rankalltime'] 	. ')<br/><br/>';
		
	} // foreach
	
} // else
?>